package er;

import java.util.ArrayList;
import java.util.List;

class Solution {
    public List<Boolean> prefixesDivBy5(int[] A) {
        List<Boolean> list = new ArrayList<>();
        int sum = 0;
        for (int i = 0; i <A.length ; i++) {
            sum = sum*2 +A[i];
            Boolean flag = (sum % 5 == 0 );
            list.add(flag);
        }

        return null;
    }

    public static void main(String[] args) {
        int sum = 6;
        sum = sum*2 +3;
        System.out.println(sum);
        Boolean flag = (sum % 5 == 0 );
        System.out.println(flag);
    }
}

class Solution2 {
    public List<Boolean> prefixesDivBy5(int[] A) {
        List<Boolean> list = new ArrayList<Boolean>();
        int sum = 0;
        int length = A.length;
        for (int i = 0; i < length; i++) {
            sum = ((sum << 1) + A[i]) % 5;
            list.add(sum == 0);
        }
        return list;
    }
}

